package com.roocon.thread.net;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.LongAdder;

public class HttpServer2 {

  public static void main(String[] args) throws IOException {
    ServerSocket serverSocket = new ServerSocket(8899);

    ExecutorService pool =  Executors.newCachedThreadPool();

    while (!Thread.interrupted()) {
      Socket client = serverSocket.accept();
      //new Thread(new ServerThread(client)).start();
      pool.execute(new ServerThread(client));
    }

    serverSocket.close();

    LongAdder adder = new LongAdder();

  }
}
